export default function createElement(vnode) {
  const elm = document.createElement(vnode.tag);

  Object.keys(vnode.props).forEach(key => {
    elm.setAttribute(key, vnode.props[key]);
  });

  if (vnode.text !== undefined) {
    elm.innerText = vnode.text;
  } else {
    // console.log(vnode);
    vnode.children.forEach(cVnode => {
      const celm = createElement(cVnode);
      elm.appendChild(celm);
    });
  }

  vnode.elm = elm;
  return elm;
}
